/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package planocontas.classes;

import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Gabi
 */
public class ConsultaPlanoContasTableModel extends AbstractTableModel{
    public List<PlanoContas> listaPlanoContas;
    private String[] colunas = {"Código", "Descrição"};

    public ConsultaPlanoContasTableModel(List<PlanoContas> listaPlanoContas){
        this.listaPlanoContas = listaPlanoContas;
    }

    public int getRowCount() {
        return listaPlanoContas.size();
    }

    public int getColumnCount() {
        return colunas.length;
    }

    public Object getValueAt(int rowIndex, int columnIndex) {
        PlanoContas planoContas = listaPlanoContas.get(rowIndex);
        if (columnIndex == 0) {
            return planoContas.getIdConta();
        }else
            return planoContas.getDescricao();
    }

    @Override
    public String getColumnName(int column) {
        return colunas[column];
    }

    @Override
    public Class<?> getColumnClass(int columnIndex) {
        if (columnIndex == 0) {
            return Integer.class;
        } else{
            return String.class;
        }
    }
}
